package edu.mse.camel.client.posterboard.ui.actions;

import org.eclipse.gef.editparts.ZoomManager;
import org.eclipse.gef.ui.parts.GraphicalEditor;
import org.eclipse.jface.action.Action;

/**
 * @author Darpan
 * Implements an action to zoom the diagram so that all of it fits in the window
 */
public class ZoomToFit extends Action {

	/* The ID of the action */
	public static final String ID = "$ZoomTF$";
	
	/* The editor that action is associated with */
	private GraphicalEditor editor;

	/*
	 * <p>Constructs the action</p>
	 * @param editor The editor that the action is associated with
	 */
	public ZoomToFit(GraphicalEditor editor) {
		super("Zoom to fit");
		setId(ID);
		//setImageDescriptor (ImageManager.getImageDescriptor(ImageManager.ID_ZOOM_TO_FIT));
		setToolTipText("Zoom to fit");
		this.editor = editor;
	}


	/*
	 * <p>Executes the action.</p>
	 */
	public void run() {
		ZoomManager zm = (ZoomManager) editor.getAdapter(ZoomManager.class);
		zm.setZoomAsText(ZoomManager.FIT_ALL);
	}

}